<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<meta name="keywords" content="">
		<meta name="description" content="">
		<link rel="stylesheet" href="http://cmanage.shinechain.io/vendor/css/weuix.min.css" />
		<link rel="icon" type="image/png" href="http://cmanage.shinechain.io/imgs/favicon.ico" />
		<title>区块链推广管理中心</title>
	</head>
	<style>
		body{
			background: #ffffff;
		}
		.main{
			width: 80%;
			margin: 0 auto;
		}
		.main>.title{
			text-align: center;
			margin-top: 5%;
		}
		#template{
			display: none;
		}
	</style>

	<body>
		<div class='main' style="position: relative;">
		<a href="/telegram.html" style="position: absolute; top: -10px;"><img src="http://cmanage.shinechain.io/imgs/return.jpg" height="48" width="48" style="vertical-align:middle;" /></a>
		<p><h2 class='title'>入群欢迎语</h2></p>
	<div class="weui_cells_title">说明：若文本中加入*用户*，则可以引用用户名，例如设置文本为“欢迎*用户*进群”，当用户李三进群，则机器人会说“欢迎李三进群”</div>
	<div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_bd weui_cell_primary">
                <textarea class="weui_textarea"  id="mytextarea" placeholder="请输入文本" rows="3"></textarea>
                <div class="weui_textarea_counter"><span class="count" id="count">0</span>/<span class="count_max" id="count_max">500</span></div>
            </div>
        </div>
    </div>
	<div class="weui_btn_area">
        <a id="formSubmitBtn" href="javascript:" class="weui_btn weui_btn_primary">提交</a>
    </div>
    <div class="weui-cells">
  <div class="weui-cell">
    <div class="weui-cell__bd">
      <p>当前欢迎语:</p>
    </div>
    <div class="weui_cells_title" id="welcomeMsg"></div>
  </div>
</div>
</div>

		<script src='http://cmanage.shinechain.io/vendor/js/zepto.min.js'></script>
<script>
$(function(){
	var ip = 'http://bot.shinechain.io';
 	var getInfo = function () {
			$.get(ip + '/botApi/getAll', function(res) {
				$('#welcomeMsg').text(res.welcome);
				})
			}
			getInfo();		
	$('textarea').on('input', function(){
		var max =  $(this).parent().find('.count_max').text();
		var text = $(this).val();
		var len = text.length;
		$(this).parent().find('.count').text(len);    
		if(len > max){
			$(this).closest('.weui_cell').addClass('weui_cell_warn');
		} else {
			$(this).closest('.weui_cell').removeClass('weui_cell_warn');
		}
	});
  
  
  $('#formSubmitBtn').click(function(){
	var text = $('#mytextarea').val();
	
	var self =  $('#welcomeMsg');
	var jsonArr = {'welcome':text}
	if (true){
		$.ajax({
                    url: ip + '/botApi/welcome',
                    type: 'POST',
                    contentType: "application/json; charset=utf-8",
                    dataType: 'json',
                    data: JSON.stringify(jsonArr),
                    success: function(res) {
                        self.text(res.welcome);
                    },
        })
	}
  });
})
</script>
</body>
</html>